package com.touni.designpattern.abstractfactorypattern.abfactory;

import com.touni.designpattern.abstractfactorypattern.abfactory.factory.CircularShape;
import com.touni.designpattern.abstractfactorypattern.abfactory.factory.Color;
import com.touni.designpattern.abstractfactorypattern.abfactory.factory.RectangleShape;
import com.touni.designpattern.abstractfactorypattern.abfactory.factory.Shape;

/**
 * @ClassName : ShapeFactory
 * @Description :
 * @Author : lwq
 * @Date: 2020-10-19 09:10
 */
public class ShapeFactory extends AbstractFactory {
    @Override
    public Shape getShape(String shapeName) {
        if (shapeName == null){
            throw new RuntimeException("shapeName must not be null!");
        }else if (shapeName.equalsIgnoreCase("rectangle")){
            return new RectangleShape();
        }else if (shapeName.equalsIgnoreCase("circular")){
            return new CircularShape();
        }else {
            throw new RuntimeException("no such shape!!");
        }

    }

    @Override
    public Color getColor(String colorName) {
        throw new RuntimeException("use error factory");
    }
}
